var url='login';
function showpass(obj,passid){
	passid=(zeai.empty(passid))?'pwd':passid;
	if (o(passid).type == 'password'){
		o(passid).type = 'text';obj.html('&#xe62b;');
	}else{
		o(passid).type = 'password';obj.html('&#xe61c;');
	}
}

/*yzm*/
function verifyFn(yzmbtn){
	if (zeai.ifmob(o('mob').value)){
		if (!yzmbtn.hasClass('disabled')){ajax_click_yzmFn();}
	}else{
		zeai.msg('请输入手机号码');return false;
	}
}
function ajax_click_yzmFn(){
	zeai.ajax({url:url+zeai.ajxext+'submitok=ajax_click_yzm'},function(e){var rs=zeai.jsoneval(e);
		zeai_yzm_em.html(rs.key);
		zeai_yzm_li.html(rs.li);
		zeai.mask({son:zeai_yzm,maskcls:'mask_TRnav'});
		zeai.listEach(zeai.tag(zeai_yzm_li,'li'),function(obj){
			obj.onclick=function(){zeai_yzm_liFn(rs.key,this.innerHTML);};
		});

	});
}
function zeai_yzm_liFn(key,v){
	zeai.ajax({url:url+zeai.ajxext+'submitok=ajax_click_yzm_chk',data:{key:key,v:v}},function(e){var rs=zeai.jsoneval(e);
		zeai.msg(0);
		if(rs.flag==1){
			zeai_yzm.hide();
			setTimeout(function(){
				if (!yzmbtn.hasClass('disabled')){
					yzmbtn.addClass('disabled');
					zeai.ajax({url:url+zeai.extname,data:{'submitok':'ajax_reg_verify',mob:o('mob').value,key:key,v:v}},function(e){
						var rs=zeai.jsoneval(e);
						zeai.msg(0);
						if (rs.flag == 1){
							zeai.msg(rs.msg,{time:5});o('verify').value='';yzmtimeFn2(120);
						}else{
							zeai.msg(rs.msg);yzmbtn.removeClass('disabled');
						}
						Mzeai_yzm.click();
					});
				}
			},200);			
		}else{
			zeai.msg(rs.msg);
			setTimeout(function(){ajax_click_yzmFn();},1000);
		}
	});
}
function yzmtimeFn2(countdown){
	var yzmbtn=o('yzmbtn');
	if (countdown == 0) {
		yzmbtn.removeClass('disabled');yzmbtn.html('<font>重新获取</font>');return false;
	} else { 
		yzmbtn.addClass('disabled');yzmbtn.html("重新发送<b>"+countdown+"s</b>");countdown--; 
	} 
	cleandsj=setTimeout(function(){yzmtimeFn2(countdown)},1000);
}

/*forgetpass*/
function forgetpassFn(){
	var mobV = o('mob2').value,verifyV=o('verify2').value,newpass=o('newpass').value;
	if(!zeai.ifmob(mobV)){zeai.msg('请输入正确手机号');return false;}
	if(!zeai.ifint(verifyV) || zeai.str_len(verifyV)!=4 ){zeai.msg('请输入【手机验证码】');return false;}
	if(zeai.str_len(newpass)>20 || zeai.str_len(newpass)<6){zeai.msg('请输入【新密码】6~20长度');return false;}
	zeai.ajax({url:'login'+zeai.ajxext+'submitok=login_forgetpass_update',form:WWW__ZEAI_CN_form2},function(e){var rs=zeai.jsoneval(e);
		zeai.msg(0);zeai.msg(rs.msg);
		if(rs.flag==1){WWW__ZEAI_CN_form2.hide();ok.show();newpassstr.html(rs.newpass);}
	});
}
function forgetpass_btnFn(){ZeaiM.div_up({obj:forgetpassbox,h:30});}

function regbtnFn(){
	if(reg_kind==2){
		var unameV = o('uname').value;
		var pwdV   = o('pwd').value;
		if(zeai.str_len(unameV) < 1 || zeai.str_len(unameV)>15){zeai.msg('请输入登录用帐号(必须为3-15字符长度)',o('uname'));return false;}
		if(zeai.str_len(pwdV)<6 || zeai.str_len(pwdV)>20){zeai.msg('请输入登录密码(必须为6-20字符长度)',o('pwd'));return false;}
	}else{	
		var mobV = o('mob').value,verifyV=o('verify').value;
		if(!zeai.ifmob(mobV)){zeai.msg('请输入正确手机号',o('mob'));return false;}
		if(!zeai.ifint(verifyV)){zeai.msg('请输入手机验证码',o('verify'));return false;}
	}
	zeai.ajax({url:'reg_alone'+zeai.extname,js:1,form:WWW__ZEAI_CN_form},function (e){var rs=zeai.jsoneval(e);
		if (rs.flag==1){
			if(reg_kind==1)clearTimeout(cleandsj);
			zeai.msg(rs.msg);
			setTimeout(function(){zeai.openurl(rs.jumpurl);},1000);
		}else{
			zeai.msg(rs.msg,{time:4});
		}
	});
}


window.onload=function(){
	if(reg_kind==2){
		forgetpass_btn.onclick=forgetpass_btnFn;
		zeai.verify({mob:mob2,verify:verify2,yzmbtn:yzmbtn2,url:MHOST+'/login.php?submitok=ajax_get_verify&kind=forgetpass_u',sec:120});
	}
	clause.onclick=function(){ZeaiM.div_left({obj:clausebox});}

}
